public class Statistics {

	String log[];
	double mallocTime;
	int numDefrag;
	int numFailMalloc;
	int sizeFailMalloc;
	double numMalloc;
	double avgBucket;
	double avgQuick;

	int numStatus;

	public Statistics(int size)
	{
		log = new String[size];
		numStatus = 0;		
		mallocTime = 0;
		numMalloc = 0;
		numDefrag = 0;
		numFailMalloc = 0;
		sizeFailMalloc = 0;
		avgBucket = 0;
		avgQuick = 0;
	}

	public void addStatus(String status)
	{
		if (numStatus >= log.length)
		{
			String temp[] = new String[log.length * 2];
			for (int i = 0; i < numStatus; i++)
				temp[i] = log[i];
			log = temp;
		}
		log[numStatus] = status;
	}

	public void next()
	{
		numStatus++;
	}

	public void addTime(double time)
	{
		mallocTime += time;
		numMalloc++;
	}
	
	public double avgMalloc()
	{
    if (numMalloc == 0)
      return 0;
		return mallocTime/numMalloc;
	}
	
	
	public void addDefrag()
	{
		numDefrag++;
	}

	public void addSize(int size)
	{
		sizeFailMalloc += size;
		numFailMalloc++;
	}
	
	public int avgSizeFail()
	{
		if(numFailMalloc != 0)
			return sizeFailMalloc/numFailMalloc;
		else return 0;
	}
	
	public void addBucket(double d)
	{
		avgBucket += d;
	}
	
	public double avgBucket()
	{
    if (numDefrag == 0)
      return 0;
		return avgBucket/numDefrag;
	}
	
	public void addQuick(double d)
	{
		avgQuick += d;
	}
	
	public double avgQuick()
	{
    if (numDefrag == 0)
      return 0;
		else return avgQuick/numDefrag;
	}
}